<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .father{
            width: 400px;
            height: 400px;
            background-color: pink;
            margin: 100px;
            overflow: hidden;
            position: relative;
        }
        .son{
            width: 150px;
            height: 150px;
            background-color: purple;
            position: absolute;
        }
    </style>
    <script src="../jquery.min.js"></script>
</head>
<body>
    <div class="father">
        <div class="son"></div>
    </div>

    <script>
        $(function(){
            //1获取设置距离文档的位置(偏移) offset 以文档为基准进行偏移
            console.log($('.son').offset());
            console.log($('.son').offset().top);
            // $('.son').offset({
            //     top:200,
            //     left:200
            // })
            //2.获取距离带有定位父亲位置(偏移)position 如果没有带有定位的父亲,则以文档为准
            //只能获取不能设置
            console.log($('.son').position());

        })
    </script>
</body>
</html>